﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using SGLisp;

public class waitAction : BlockAction
{
    float WaitTime;
    DateTime endTime;
    public override void OnLoad(List<ASTNode> args)
    {
        this.IsFinish = false;
        this.WaitTime  =(float)((NumberNode)args[1]).NumberVal;
    }

    public override void OnExec(Context context) 
    {
        this.IsFinish = false;
        this.endTime = DateTime.Now.AddMilliseconds(WaitTime * 1000);        
    }
    public override void Update()
    {
        if (DateTime.Now.Ticks >= endTime.Ticks) 
        {
            this.IsFinish = true;
        }
    }
}
